package com.wy.redis;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
@Configuration
public class JedisConfig extends CachingConfigurerSupport {
    private static Logger logger = (Logger) LoggerFactory.getLogger(JedisConfig.class);
    @Value("${spring.redis.host}")
    private  String host;
   @Value("${spring.redis.port}")
    private int port;
    @Value("${spring.redis.password}")
    private  String password;
   @Value("${spring.redis.database}")
    private int database;
    @Bean
   public  JedisPool jedisPoolFactory(){
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
       jedisPoolConfig.setMaxTotal(10);
        JedisPool jedisPool = new JedisPool(jedisPoolConfig,host,port,0,password,database);
       logger.info("JedisPool注入成功");
       return jedisPool;
    }
}
